/*
 * Tableau3D.cpp
 *
 *  Created on: 2 nov. 2012
 *      Author: Ionel MOREAU-SEREZ
 */

#include"Tableau3D.h"

void initialiser(Tableau3D& t, unsigned int x, unsigned int y, unsigned int z){
	assert((x>0) && (y>0) && (z>0));
	t.dimX = x;
	t.dimY = y;
	t.dimZ = z;
	t.tab = new ItemT3D**[x];

	for(int i=0; i<x; ++i){
		t.tab[i] = new ItemT3D*[y];
			for (int j = 0; j < y; ++j) {
				t.tab[i][j] = new ItemT3D[z];
		}
	}
}

void detruire(Tableau3D& t){
	for(int i=0; i<t.dimX; ++i){
		for (int j = 0; j < t.dimY; ++j) {
				delete [] (t.tab[i][j]);
		}
		delete [] (t.tab[i]);
	}
	delete [] (t.tab);

	t.tab=NULL;
}

void afficher(Tableau3D& t){

	cout << endl;

	ItemT3D item;

	for(unsigned int i = 0; i < t.dimZ ; ++i){
		for( unsigned int y = 0; y < t.dimY; ++y){
			for( unsigned int x = 0; x < t.dimX; ++x){
				item = t.tab[x][y][i];
				switch(item){
							case PASSAGE :
								cout << "+";
							    break;
							case MUR :
								cout << "#";
					            break;
							case DRAGON :
								cout << "D";
							    break;
							case TRESOR :
								cout << "T";
							  break;
							}
			}
			cout << endl;
		}
		cout << endl;
	}
}
